package com.inet.observer;

import com.inet.receiver.MyHandler;
import com.inet.util.L;

import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
import android.provider.Settings.SettingNotFoundException;
import android.util.Log;

public class ACCObserver extends ContentObserver{
	
	private Context mContext;
	private MyHandler mHandler;
	public ACCObserver(Handler handler,Context context) {
		super(handler);
		mHandler=(MyHandler) handler;
		mContext=context;
	}
	
	
	@Override
	public void onChange(boolean selfChange) {
		super.onChange(selfChange);
		L.i("ACCObserver receive ACC Changed");
		try {
			int isACC_OFF=android.provider.Settings.System.getInt(mContext.getContentResolver(),"acc_state");
			//isACC_OFF==1 ,表示ACCON
			L.i("ACCObserver isACC_OFF=="+isACC_OFF);
			if(isACC_OFF==1){
				mHandler.sendEmptyMessageDelayed(MyHandler.STARTVIDEO, 7000);
			}else if(isACC_OFF==0){
				mHandler.removeMessages(MyHandler.STARTVIDEO);
			}
		} catch (SettingNotFoundException e) {
			e.printStackTrace();
		}
	}
	
}
